<?php
/**
 * 用户
 *
 *
 */


class category_model extends CI_Model
{
	const tableName = "category";
	
	var $name;

	var $restaurantId;

	function __construct()
	{
		parent::__construct();
	}

	// --------------------------------------------------------------------

	/**
	 *
	 * 插入user数据
	 */
	function insert_entry($date)
	{
		$this->name = $date['name'];	
		$this->restaurantId = $date['restaurantId'];
		
		$this->db->insert(self::tableName, $this);
	}
	
	function getCategoryByRestaurantid($restaurantID)
	{
		$query = $this->db->query("select * from ".self::tableName." where restaurantId = {$restaurantID}");
		//$query = $this->db->query("select * from ".self::tableName." where resutaurantId = ".$restaurantid);
		return $query->result() ;		
	}
	
	function getCategoryByIdarray($categoryIDArray)
	{
		if(count($categoryIDArray)<=0)
		{
			return array();
		}
		$categoryIdStr = implode(',', $categoryIDArray);
		$categoryIdStr = substr($categoryIdStr, 2);
		$query = $this->db->query("select * from ".self::tableName." where id in ({$categoryIdStr}) order by rank");
		//$query = $this->db->query("select * from ".self::tableName." where resutaurantId = ".$restaurantid);
		return $query->result() ;
		
	}
}